/**
 * @Copyright 2012, Founder Mobile Media Technology（Chongqing） Co., Ltd L.P. All
 *            rights reserved. The information contained herein is confidential
 *            and proprietary to Founder Mobile Media Technology（Chongqing） Co.,
 *            Ltd, and considered a trade secret as defined under civil and
 *            criminal statutes. Founder Mobile Media Technology（Chongqing） Co.,
 *            Ltd shall pursue its civil and criminal remedies in the event of
 *            unauthorized use or misappropriation of its trade secrets. Use of
 *            this information by anyone other than authorized employees of
 *            Founder Mobile Media Technology（Chongqing） Co., Ltd is granted
 *            only under a written non-disclosure agreement, expressly
 *            prescribing the scope and manner of such use.
 */
package com.g2room.base64;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;

import sun.misc.BASE64Decoder;
import sun.misc.BASE64Encoder;

/**
 * 
 * 
 * @createTime: May 15, 2013 4:34:16 PM
 * @author: <a href="mailto:gaoxg@FOUNDER.COM.CN">Xuguo Gao</a>
 * @version: 0.1
 * @lastVersion: 0.1
 * @updateTime:
 * @updateAuthor: <a href="mailto:gaoxg@FOUNDER.COM.CN">Xuguo Gao</a>
 * @changesSum:
 * 
 */
public class Base64Utils {
	/**
	 * 将指定字符串进行base64编码
	 * 
	 * @param {String}
	 *            str 需要进行base64编码的字符串
	 * @return {String} base64编码后的字符串
	 * @auther <a href="mailto:gaoxg@FOUNDER.COM.CN">Gao Xuguo</a> May 15, 2013
	 *         4:41:24 PM
	 */
	public static String encode(String str) {
		String sr = null;
		if (null != str) {
			BASE64Encoder base64 = new BASE64Encoder();
			sr = base64.encode(str.getBytes());
		}
		return sr;
	}

	/**
	 * 对传入的字符串进行base64解码
	 * 
	 * @param {String}
	 *            str 需要解码的字符串
	 * @return {String} 解码后的字符串
	 * @auther <a href="mailto:gaoxg@FOUNDER.COM.CN">Gao Xuguo</a> May 15, 2013
	 *         4:43:37 PM
	 */
	public static String decode(String str) {
		String rs = null;
		if (null != str) {
			BASE64Decoder decoder = new BASE64Decoder();
			try {
				rs = new String(decoder.decodeBuffer(str));
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
		return rs;
	}
	
	/**
	 * 
	 * 图片文件转换字节数组，再为BASE64编码字符串
	 *
	 * @param {String} imgFile 图片路径
	 * @return {String} 转换后的图片内容
	 * @auther <a href="mailto:gaoxg@FOUNDER.COM.CN">Gao Xuguo</a>
	 * May 15, 2013 5:25:40 PM
	 */
	public static String GetImageStr(String imgFile) {
		InputStream in = null;
		byte[] data = null;
		// 读取图片字节数组
		try {
			in = new FileInputStream(imgFile);
			data = new byte[in.available()];
			in.read(data);
			in.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
		// 对字节数组Base64编码
		BASE64Encoder encoder = new BASE64Encoder();
		// 返回Base64编码过的字节数组字符串
		return encoder.encode(data);
	}

	/**
	 * 对字节数组字符串进行Base64解码并生成图片
	 *
	 * @param {String} imgData 图片数据字符串
	 * @param {String} imgFile 图片路径
	 * @return {Boolean} 成功则返回true，失败则返回false
	 * @auther <a href="mailto:gaoxg@FOUNDER.COM.CN">Gao Xuguo</a>
	 * May 15, 2013 5:26:30 PM
	 */
	public static boolean GenerateImage(String imgData, String imgFile) {
		if (imgData == null) return false;
		BASE64Decoder decoder = new BASE64Decoder();
		try {
			// Base64解码
			byte[] b = decoder.decodeBuffer(imgData);
			for (int i = 0; i < b.length; ++i) {
				if (b[i] < 0) {
					// 调整异常数据
					b[i] += 256;
				}
			}
			// 生成jpeg图片
			OutputStream out = new FileOutputStream(imgFile);
			out.write(b);
			out.flush();
			out.close();
			return true;
		} catch (Exception e) {
			return false;
		}
	}
	

	// 转化十六进制编码为字符串
	public static String toStringHex(String s) {
		byte[] baKeyword = new byte[s.length() / 2];
		for (int i = 0; i < baKeyword.length; i++) {
			try {
				baKeyword[i] = (byte) (0xff & Integer.parseInt(s.substring(
						i * 2, i * 2 + 2), 16));
			} catch (Exception e) {
				e.printStackTrace();
			}
		}

		try {
			s = new String(baKeyword, "utf-8");// UTF-16le:Not
		} catch (Exception e1) {
			e1.printStackTrace();
		}
		return s;
	}

	public static void main(String[] str) {
//		String s64 = "504b0304140008000800d364144300000000000000000000000005000000302e7478743d906b6e82501085ffbb0a57d084fac2dd81d6208a22a24585c447d5da286aea8b00ea626066b8bfdc422f35edbf7bcf7ce74cce80b;182f9272d75aaba283799dbc3439fec2ec96bae40286163f60865681dd05a24a74ba21c4474ea39817f1fa1068a8bee1cea5e319f2b6505512c65f3afc542562c08058e426d05f615fe76306b05bec56db1bf66e699f5e44892d3477701da50;805a95de77bf0b35d25ba44f506d32f3c621ba4fe93ea1b68aea47b9cc4136ec3045e76c7274398ef6111d153505b62316bc31c5608b3d98b2f8226263c001d60d687c883d1337b7d24b898b3c01adf33321922ad8dfa7818ecaf534b03183a;d96d676677c9a5c37a01bb1ff0d7a33f624e868a05762affdb4a7b7bb6ef99992dd32d9cd78473006dc15499dffee91646432e87db1e50af50ecdfd47388a7d8d82234d64b06fa42ac9ee42f7804d4f385e90d3fc01504b07081060242b4a01;00009b010000504b0304140008000800d364144300000000000000000000000005000000312e706e67eb0cf073e7e592e2626060e0f5f4700902d26741988309484eb9976cc7c0c01ce5e9e2185271ebededc049870c785c0edef97fa980c35;bf9e8cbefa7859a2ee74c2da8a80baaef5715487fe4f3c8674ea771a771a15aa1dab923338fccb4986c218c5bf8d6ab379ea54561ade76d2d9f1f523e1e36c9f89cc5e31e28b16a7dc6fdafefaa171ee27f3869ea931e84d4e6356d377689cf;737be8f2f318aa84efeacbdb758dbf8a210c01892e38e474f0bbefbb3985c724d3a1c4b53f7249e675b11f7605bb3f4356fa8c6bf9c5701ba9684f247758ec5ebaaf77d9dce67bd3529f23d4bed13eb76cd9e6439bbb36be8e7eaebacf12a1f;cf7aacdfb566f7aa2aedbfa3ce6c71dd566dd74249b53d9f7ae5c1df4c3a976fb94bbf5f39591a432d337de9db4efa6ae59be5ee514e470d8e4bdb338ad67610feff2eff5eb0fc2bd70ece6abcacd05526f2f1b6ce50db508f4e3bd82644ded;d59b5f2f47266e9c2cf3fb389216c9f4bddf43be6adeb11439ce5689ecc5d56562d16bf6e5aeb871deb92c6f0d52401dbbf931fa56a68919ab7fed04e4505d2319763f7586946272fd9d720d6493a2cfe465a5af2c28997b08c5dec59fd3723;cee18156c9dbbf9bd29b2729b7c3fde6dc1c10fcf0916bd2a334132c9eef11bcfabeecb3f5cb493d9588c12498fb5ad4a9fd8f1b6ca6f5ef973167248cd3215b9172c3a7b43d2e7b4fb7f9143bdb06ce5e61b7b2ccbf4c3b352508cca3f33bb;55da573dfb6bd7cbd92869ef7a6d56da9bdb1f34557e77f5aa21fb4f7aef81dae9fb0bbcd34fd69c45f6a010b6542e8c5f38fa17f3e40576ac93f625a603331b83a7ab9fcb3aa7842600504b070891f740375e02000093030000504b0304140;008000800d36414430000000000000000000000000900000074656d702e736d696c75905f4fc23014c5dff914d7fbceba3151631824023124a84bc0071f272b5d93ae6ddacec1b7f78ea121fee9cbed6dcfeff69c4e66875ac107775e1a9d61;12c5085cef4c29b5c8b009fbe11d820f852e0b6534cff0c83dcea683c9d5e265be7dcb97e06ba9207f7d58afe68043c6d2c73c676cb15dc0e669b506c7d598b1e533025621d87bc6dab68d52616d649c609d6614b37cb319234d3d0d2347da6;797f2363d8947719c7c11eb428ba610bca32a5e94545471344da08d33260cfb0e2a2e4515321c5f53b25696a1ca30bd8991753a2e2835ec25ddd79c07045952686bb943507c4fc7040563bbfa13f03b6794ea1165dadfc8e8b687d8b72f7636;fa6eca23155b38281b474412d3aa7d9725f04380fe9d6f2bdeed48148543e80712f81f2e6bf1279d44568b4b9a9d4db0eecba7834f504b07082abd75703201000008020000504b01021400140008000800d36414431060242b4a0100009b010;000050000000000000000000000000000000000302e747874504b01021400140008000800d364144391f740375e0200009303000005000000000000000000000000007d010000312e706e67504b01021400140008000800d36414432abd7570;320100000802000009000000000000000000000000000e04000074656d702e736d696c504b050600000000030003009d000000770500000000";
//		System.out.println(toStringHex(s64));
//		System.out.println(toStringHex(s64));
//		try {
//			System.out.println(toStringHex(s64).getBytes("UTF-8"));
//			System.out.println(new String(toStringHex(s64).getBytes("GBK"),"UTF-8"));
//		} catch (UnsupportedEncodingException e) {
//			// TODO Auto-generated catch block
//			e.printStackTrace();
//		}
	
		String imgFile = "E:/var/13926291946774109.jpg";
		String strImg = GetImageStr(imgFile);
		System.out.println(strImg);
		System.out.println("==========================");
		
		strImg = "/9j/4QAwRXhpZgAASUkqAAgAAAABADEBAgAOAAAAGgAAAAAAAAB3d3cubWVpdHUuY29tAP/bAEMAAwICAwICAwMDAwQDAwQFCAUFBAQFCgcHBggMCgwMCwoLCw0OEhANDhEOCwsQFhARExQVFRUMDxcYFhQYEhQVFP/bAEMBAwQEBQQFCQUFCRQNCw0UFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFP/AABEIAGkAjAMBEQACEQEDEQH/xAAfAAABBQEBAQEBAQAAAAAAAAAAAQIDBAUGBwgJCgv/xAC1EAACAQMDAgQDBQUEBAAAAX0BAgMABBEFEiExQQYTUWEHInEUMoGRoQgjQrHBFVLR8CQzYnKCCQoWFxgZGiUmJygpKjQ1Njc4OTpDREVGR0hJSlNUVVZXWFlaY2RlZmdoaWpzdHV2d3h5eoOEhYaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3uLm6wsPExcbHyMnK0tPU1dbX2Nna4eLj5OXm5+jp6vHy8/T19vf4+fr/xAAfAQADAQEBAQEBAQEBAAAAAAAAAQIDBAUGBwgJCgv/xAC1EQACAQIEBAMEBwUEBAABAncAAQIDEQQFITEGEkFRB2FxEyIygQgUQpGhscEJIzNS8BVictEKFiQ04SXxFxgZGiYnKCkqNTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqCg4SFhoeIiYqSk5SVlpeYmZqio6Slpqeoqaqys7S1tre4ubrCw8TFxsfIycrS09TV1tfY2dri4+Tl5ufo6ery8/T19vf4+fr/2gAMAwEAAhEDEQ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R0oe9iKkqj9bL7kewsNhoK3s/myXUo9VtNG1B4NTu0ZoGQB3LhgeMEH61tXy3DRg5U04tdm/xvdM56tLDWtyI5H4IeAIm8Ypc3Y8p4lIhcDq56/pnivJowvNKez6ni4yUo0/d1RhfGX4ODS/F2oTxQrEtw3m/ux8pychhXQ6bpzcJCw+I5qd0zz248FyQFLyJMOGy4x0YcEfjVRhdcrN/aW1RNceF9zefGu0tyT/SslStozrlXuro7/wADeK9S8LaIbGCd4YxKzhVPHIH+FaQlKmuVHn4ilDEz9pLc+hV/17/Wvv2fBhqv+orWO5yVdjh9S6n611x2PM6lbT+v41k9zRbF5f8AXn6Vb2MvtI81+IX/ACE7b/rm386+Izb+IfoOSfwDov8AmRT9FrBfwn/hNn/Gj/iZwum/8hWL/rqP5Vx4b+IvVHZjP4E/Q9s8E/8AJNPGX/XYfyFfT5vsfJZN09WQfCb/AJAuu/8AXYf+g1+cVdpH2E/iRJYf6uL6t/Ov0DDf7rS/wn0UfhRrxdq0j0OafxjNc/5Ac/0H865sR/DZzzKHgD7v/byleJ/zCz/xI4p/w5G38a/+XP8A64Sf+hV14neHoePhdpHh11/x7Xn+8P5VkviR6b+FmUP9V+NTMuOw2H7n+fSs3ubLZH//2Q==";
        GenerateImage(strImg, "E:/var/4.jpg");
//        String content = "1120**000020110001000000920000000530KCF";
//        content = content.replace("**", content.length()+"");
//        System.out.println("=========="+content);
		String name = "http://www.baidu.com";
//		try {
////			name = new String(content.getBytes("GBK"));
//		} catch (UnsupportedEncodingException e1) {
//			// TODO Auto-generated catch block
//			e1.printStackTrace();
//		}
//        content = "2013年10月29日15时42分55秒";
//		String en = "MTAxMDQwMDAxMTMxOTAwMDAzMDAwMDA1MjcwMTAwMDAwNTI3aHl4dA==";
////		en = Base64Utils.encode(en);
//		System.out.println(en);
//		en = "MTAxMDQwMDAxMTMxOTAwMDAzMDAwMDA1MjcwMTAwMDAwNTI3aHl4dA==";
//		String de = Base64Utils.decode(en);
//		System.out.println(de);
//		try {
//			System.out.println(new String(de.getBytes("GBK"),"utf-8"));
//			System.out.println(new String(de));
//			System.out.println(new String(de.getBytes("UTF-8")));
//			System.out.println(new String(de.getBytes("GBK")));
//			System.out.println(new String(de.getBytes("GB2312")));
//////			System.out.println(new String(de.getBytes("GBK"),"utf-8"));
//////			System.out.println(new String(de.getBytes("GBK"),"utf-8"));
//		} catch (UnsupportedEncodingException e) {
//			// TODO Auto-generated catch block
//			e.printStackTrace();
//		}
		
////		en="MjQ2NDE4ODc1OTMyOTAxN0E3RkRGNzgwRw==";
//		de = Base64Utils.decode(en);
//		try {
//			System.out.println(new String(de.getBytes("GBK"),"UTF-8"));
//		} catch (UnsupportedEncodingException e) {
//			// TODO Auto-generated catch block
//			e.printStackTrace();
//		}
		
		
//		en="MTExMDM5MDAwMDEwMTAwMDAxMDAwMDA1MjAwMTAwMDAwNTIwS0NG";
//		//220200000386
////		en = "TjrlvKDlsbE7VElMOuaAu+ebkTtESVY654mp6IGU572R5LqL5Lia6YOoO0NPUjrmlrnmraPnp7vliqg7QURSOuaWueato+WbvemZheWkp+WOpjEx5bGCO1pJUDoxMDAwODA7VEVMOjYyNjkxMTExLTExMDtNOjEzNzAxMDIyMTAxO0ZBWDo2MjY5MTExMS04MDQ7RU06emhhbmdzaGFuQGZvdW5kZXIuY29t";
////		System.Text.Encoding.Unicode.GetString(en);
//		de = Base64Utils.decode(en);
//		try {
//			System.out.println(new String(de.getBytes("GBK"),"UTF-8"));
//		} catch (UnsupportedEncodingException e) {
//			// TODO Auto-generated catch block
//			e.printStackTrace();
//		}
//		System.out.println(de);
	}
}
